<template>
  <el-dialog title="读取收藏" :visible.sync="dialogTableVisible">
    <el-table
      :data="gridData"
      highlight-current-row
      ref="singleTable"
      @current-change="handleCurrentChange"
      height="250"
    >
      <el-table-column
        property="name"
        label="名称"
      ></el-table-column>
      <el-table-column
        property="created_at"
        label="日期"
      ></el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handleSelect"
        >确 定</el-button
      >
    </div>
  </el-dialog>
</template>
<script>
import {Message} from "element-ui"
import Api from "@/api/companyMap";
export default {
  data() {
    return {
      gridData: [
       
      ],
      currentRow:'',
      dialogTableVisible: false,
    };
  },
  created(){
   // this.mapList()
  },
  methods: {
    open() {
      this.mapList()
      this.dialogTableVisible = true;
    },
    mapList(){
        Api.fetchMapList({},
        (success)=>{
                console.log(success)
                this.gridData=success.data
        })
    },
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    handleSelect(){
        if(!this.currentRow){
            Message.error('请选择一条数据')
            return
        }
        this.dialogTableVisible=false
        console.log(this.currentRow)
        this.$emit('handleSelect',this.currentRow)
    }
  },
};
</script>